/// <reference path="jquery.min.js" />

$(document).ready(function () {
    $("input#add").click(function () {
        add();
    });
    $("input#new").keypress(function (e) {
        if (e.which == 13) {
            add();
        }
    });
});

function add() {
    var name  = $('input#new').val();
    
    $.getJSON("/scripts/niveau.json", function (result) {
        
        if (result != null && result.hasOwnProperty("id")) {
            $('div#niveaux').append('<div id="' + result.id + '">' + result.name + '</div>');
        }
    });
}
